package com.filter;

import javax.servlet.*;
import java.io.IOException;

public class EncodeFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("初始化加载");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
             /*目前来说统一处理乱码*/
             System.out.println("开始处理乱码");
             request.setCharacterEncoding("utf-8");

             //放行
             filterChain.doFilter(request,response);

             response.setCharacterEncoding("utf-8");

    }

    @Override
    public void destroy() {
        System.out.println("销毁");
    }
}
